<!DOCTYPE HTML>
<html>
<head>
<title>SetCapsLockState / SetNumLockState / SetScrollLockState | AutoHotkey</title>
<meta name="description" content="The SetCapsLockState, SetNumLockState and SetScrollLockState commands set the state of the corresponding key. Can also force the key to stay on or off." />
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>SetCapsLockState / SetNumLockState / SetScrollLockState</h1>

<p>设置 <kbd>CapsLock</kbd>/<kbd>NumLock</kbd>/<kbd>ScrollLock</kbd> 键的状态. 还可以强制此键保持打开或关闭状态.</p>

<pre class="Syntax">
<span class="func">SetCapsLockState</span> <span class="optional">, State</span>
<span class="func">SetNumLockState</span> <span class="optional">, State</span>
<span class="func">SetScrollLockState</span> <span class="optional">, State</span>
</pre>
<h2>参数</h2>
<dl>

  <dt>State</dt>
  <dd><p>如果省略此参数, 则清除按键的 AlwaysOn/Off 状态(如果存在). 否则, 请指定下列单词的其中一个:</p>
      <p><strong>On</strong>: 打开按键并清除按键的 AlwaysOn/Off 状态(如果存在).</p>
	  <p><strong>Off</strong>: 关闭按键并清除按键的 AlwaysOn/Off 状态(如果存在).</p>
      <p><strong>AlwaysOn</strong>: 强制按键保持打开状态.</p>
      <p><strong>AlwaysOff</strong>: 强制按键保持关闭状态.</p>
      <p><span class="ver">[v1.1.30+]:</span> 可以分别使用十进制值 1 和 0 代替 On 和 Off.</p>
</dd>

</dl>

<h2>备注</h2>
<p>要把按键切换到相反的状态还可以通过 <a href="Send.htm">Send</a> 命令, 例如: <code>Send {CapsLock}</code>.</p>
<p>保持一个按键 <em>AlwaysOn</em> 或 <em>AlwaysOff</em> 需要<a href="_InstallKeybdHook.htm">键盘钩子</a>, 在这样的情况中会自动进行安装.</p>
<h2>相关</h2>
<p><a href="SetStoreCapslockMode.htm">SetStoreCapsLockMode</a>, <a href="GetKeyState.htm">GetKeyState</a></p>
<h2>示例</h2>
<pre class="NoIndent">SetNumLockState, on
SetScrollLockState, AlwaysOff</pre>

</body>
</html>